package com.qf.exhandler;


import com.qf.vo.ResultVo;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice  // 全局异常处理器注解
public class GlobalExHandler {

    @ExceptionHandler(Exception.class)
    public ResultVo handleEx(Exception e){
        e.printStackTrace(); // 打印异常信息到控制台
        ResultVo resultVo = new ResultVo();
        resultVo.setCode(500);
        resultVo.setMsg("产生异常了");
        resultVo.setData(e.getMessage());
        return resultVo;
    }

}
